package ar.uba.fi.taller2.cmmiassistant.frontend.evidencias;

import java.awt.GridBagLayout;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JButton;

import ar.uba.fi.taller2.cmmiassistant.controlador.Controlador;
import ar.uba.fi.taller2.cmmiassistant.frontend.PanelVista;
import ar.uba.fi.taller2.cmmiassistant.frontend.adaptadores.tabla.TableModelEvidencias;
import ar.uba.fi.taller2.cmmiassistant.vista.Estado;
import ar.uba.fi.taller2.cmmiassistant.vista.Vista;

import java.awt.GridBagConstraints;
import java.awt.Font;

public class MostrandoEvidencias extends PanelVista {

	private static final long serialVersionUID = 2364160696532560199L;

	private JPanel panelBotones = null;
	private JLabel labelEvidencias = null;
	private JScrollPane scrollPane = null;

	private JTable tableEvidencias = null;
	private TableModelEvidencias tableModelEvidencias = null;
	
	private JButton buttonNueva = null;
	private JButton buttonModificar = null;

    private JButton buttonBorrar;

	/**
	 * This is the default constructor
	 */
	public MostrandoEvidencias(Vista contexto) {
		super(contexto);
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		labelEvidencias = this.crearLabelTitulo("Evidencias");
		this.setSize(300, 200);
		this.setLayout(new BorderLayout());
		this.add(getPanelBotones(), BorderLayout.SOUTH);
		this.add(labelEvidencias, BorderLayout.NORTH);
		this.add(getScrollPane(), BorderLayout.CENTER);
	}

	/**
	 * This method initializes panelBotones	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getPanelBotones() {
		if (panelBotones == null) {
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
			gridBagConstraints1.gridy = 0;
			
            GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
            gridBagConstraints2.gridx = 1;
            gridBagConstraints2.anchor = GridBagConstraints.CENTER;
            gridBagConstraints2.gridy = 0;
            
            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
            gridBagConstraints3.gridx = 2;
            gridBagConstraints3.anchor = GridBagConstraints.CENTER;
            gridBagConstraints3.gridy = 0;
			
			panelBotones = new JPanel();
			panelBotones.setLayout(new GridBagLayout());
			panelBotones.setPreferredSize(new Dimension(0, 30));
			panelBotones.add(getButtonNueva(), gridBagConstraints1);
			panelBotones.add(getButtonModificar(), gridBagConstraints2);
			panelBotones.add(getButtonBorrar(), gridBagConstraints3);
		}
		return panelBotones;
	}

	/**
	 * This method initializes scrollPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setViewportView(getTableEvidencias());
		}
		return scrollPane;
	}

	/**
	 * This method initializes tableEvidencias	
	 * 	
	 * @return javax.swing.JTable	
	 */
	public JTable getTableEvidencias() {
		if (tableEvidencias == null) {
			tableEvidencias = new JTable();
			tableEvidencias.setModel(this.getTableModelEvidencias());
		}
		return tableEvidencias;
	}

	public TableModelEvidencias getTableModelEvidencias() {
	    
	    if (this.tableModelEvidencias == null) {
	        
	        this.tableModelEvidencias = new TableModelEvidencias();
	    }
	    
	    return this.tableModelEvidencias;
	}
	/**
	 * This method initializes buttonNueva	
	 * 	
	 * @return javax.swing.JButton	
	 */
	public JButton getButtonNueva() {
		if (buttonNueva == null) {
			buttonNueva = new JButton();
			buttonNueva.setText("Nueva");
		}
		return buttonNueva;
	}

    public JButton getButtonModificar() {
        if (buttonModificar == null) {
            buttonModificar = new JButton();
            buttonModificar.setText("Modificar");
        }
        return buttonModificar;
    }
    
    public JButton getButtonBorrar() {
        
        if (this.buttonBorrar == null) {
            
            this.buttonBorrar = new JButton();
            this.buttonBorrar.setText("Borrar");
        }
        return this.buttonBorrar;
    }
    
    public Estado getEstado() {

        return Estado.MOSTRANDO_EVIDENCIAS;
    }

    public void setControlador(Controlador controlador) {
        
        super.setControlador(controlador);
        this.getTableModelEvidencias().setControlador(controlador);
    }

    
    
} //  @jve:decl-index=0:visual-constraint="10,10"
